# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=graphql-cop
pkgver=1.16.r0.g2b7e086
pkgrel=1
epoch=1
pkgdesc='GraphQL vulnerability scanner.'
arch=('any')
groups=('blackarch' 'blackarch-scanner' 'blackarch-webapp')
url='https://github.com/dolevf/graphql-cop'
license=('MIT')
depends=('python' 'python-requests' 'python-simplejson')
makedepends=('git')
source=("git+https://github.com/dolevf/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md

  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a *.py lib "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
python /usr/share/$pkgname/$pkgname.py "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/$pkgname"
}

